package com.sh.data.engine.common.enumDefinition;

import org.apache.commons.lang3.StringUtils;

/**
 * @author : fuchen
 * @date : 2022/1/7 11:17
 */
public enum IndexTimeGranularityEnum {
    DAY("日", "day"),
    WEEK("周", "week"),
    MONTH("月", "month"),
    SEASON("季", "season"),
    YEAR("年", "year"),
    NOTIME("无", "none");


    private String nameCN;

    private String name;

    public String getName() {
        return name;
    }

    public String getNameCN() {
        return nameCN;
    }

    IndexTimeGranularityEnum(String nameCN, String name) {
        this.nameCN = nameCN;
        this.name = name;
    }

    public static String getIndexTimeName(String nameCN) {
        for (IndexTimeGranularityEnum indexTimeGranularity : IndexTimeGranularityEnum.values()) {
            if (StringUtils.equalsIgnoreCase(indexTimeGranularity.getNameCN(), nameCN)) {
                return indexTimeGranularity.getName();
            }
        }
        throw new IllegalArgumentException("时间类型不支持: " + nameCN);
    }

}
